package com.dream.utils;

import javax.servlet.http.Cookie;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class CookieUtil {

    public static Cookie createCookie(String key,String value,int time){
        Cookie cookie = null;
        try {
            cookie = new Cookie(URLEncoder.encode(key,"UTF-8"), URLEncoder.encode(value,"UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        cookie.setMaxAge(time);
        return cookie;
    }
}
